# -*- coding:utf-8 -*-
import httplib, urllib, json
 
#定义需要进行发送的数据   
#定义一些文件头   
headers = {"Content-Type":"application/x-www-form-urlencoded",   
                   "Connection":"Keep-Alive","Referer":"http://127.0.0.1/"};   
#与网站构建一个连接   
conn = httplib.HTTPConnection("127.0.0.1", 8001);   
#开始进行数据提交   同时也可以使用get进行   
code = '54ix6K+t56e75Yqo5byA5Y+R6ICFOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2OjE6MTk4Mw=='
code = '54ix6K+t5aWz56WeOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2OjA6MTk4Mw=='
params = urllib.urlencode({'type':'register','code':code}); 
conn.request(method="POST",url="/user",body=params, headers=headers);   
#返回处理后的数据   
response = conn.getresponse(); 
#判断是否提交成功   
print response.status
print json.dumps(json.loads(response.read()), indent = 4)

#conn = httplib.HTTPConnection("127.0.0.1", 8080);
#code = '54ix6K+t56e75Yqo5byA5Y+R6ICFOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2'
#params = urllib.urlencode({'type':'checkin','code':code}); 
#conn.request(method="POST",url="/user",body=params, headers=headers);   
##返回处理后的数据   
#response = conn.getresponse(); 
##判断是否提交成功   
#print response.status
#print json.dumps(json.loads(response.read()), indent = 4)
#
#conn = httplib.HTTPConnection("127.0.0.1", 8080);   
#params = urllib.urlencode({'type':'checkuname','uname':'爱语首席巡视员'}); 
#conn.request(method="POST",url="/user",body=params, headers=headers);   
##返回处理后的数据   
#response = conn.getresponse(); 
##判断是否提交成功   
#print response.status
#print json.dumps(json.loads(response.read()), indent = 4)
#
#conn.close();
